package com.itheima.d1_staticdemo;

public class Test2 {
    public static void main(String[] args) {
        // 目标：通过案例理解类变量的应用场景。
        User u1 = new User();
        User u2 = new User();
        User u3 = new User();
        User u4 = new User();

        System.out.println(User.number);

        //试一试那个student类的静态成员变量   不乱码了，改了file encoding里面的project encoding为utf-8
        //依旧是乱码：绫诲悕璋冪敤闈欐�佹垚鍛樺彉閲廠tudent.name: null
        System.out.println("类名调用静态成员变量Student.name: "+Student.name);
        Student s1 = new Student();
        //瀵硅薄璋冪敤闈欐�佹垚鍛樺彉閲弒1.name: null
        System.out.println("对象调用静态成员变量s1.name: "+s1.name);

        Student.name = "zengjihong";
        System.out.println(Student.name); //zengjihogn
        System.out.println(s1.name);  //zengjihong
        s1.name = "zeng";
        System.out.println(s1.name);  //zeng
        System.out.println(Student.name);  //zeng

        s1.name = "zengji";
        System.out.println(s1.name); //zengji

    }
}
